// pages/medicalRecord/medicalRecord.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    username: '',
    patientTel: '',
    orderTime: '',
    orderDate: '',
    illName: '',
    illLevel: '',
    illResult: '',
    illCare: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({   
      username: getApp().globalData.username,
      patientTel: JSON.parse(options.patientTel),
      orderDate: JSON.parse(options.orderDate),
      orderTime: JSON.parse(options.orderTime),
    })
    this.getIllRecord()
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.getIllRecord()
  },

  /**
   * 医生查看该患者于本次预约中开好的的病历
   */
  getIllRecord: function(e){
    var that = this
    wx.request({
      url: getApp().globalData.url + 'getIllRecord',
      method: 'GET',
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      data: {
        doctorTel: this.data.username,
        patientTel: this.data.patientTel,
        orderDate: this.data.orderDate,
        orderTime: this.data.orderTime
      },
      success(res) {
        that.setData({
          illName: res.data.illName,
          illLevel: res.data.illLevel,
          illResult: res.data.illResult,
          illCare: res.data.illCare,
        })
      },
      fail(res) {
        wx.showToast({
          title: '获取病历失败，请下拉刷新',
          icon: 'none',
          duration: 2000
        })
      }
    })
  }
})